package lc.位运算;

/**
 * @description:
 * @author: qian
 * @createDate: 2021/11/2
 */
public class 剑指Offer15_二进制中1的个数 {

    public int hammingWeight(int n) {

        int res = 0;
        while (n != 0) {
            res += n & 1;
            n >>= 1;
        }
        return res;
    }
}
